﻿Public Class FormAuthentication
	Public prevForm As Form

	Private Sub FormAuthentication_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

	End Sub


	Private Sub FormAuthentication_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
		Dim methodAuth As New AuthGetSession
		Dim doc As XDocument = methodAuth.getSession()
		Try
			My.Settings.sk = doc.<lfm>.<session>.<key>.Value
		Catch ex As Exception
			My.Settings.sk = ""
		End Try
		Me.DialogResult = Windows.Forms.DialogResult.OK
		ApplicationMain.Show()
	End Sub

	Private Sub FormAuthentication_Load(sender As Object, e As System.EventArgs) Handles Me.Load
		Dim methodAuth As New AuthGetToken
		Dim doc As XDocument = methodAuth.getToken()
		My.Settings.token = methodAuth.ExtractToken(doc)

		WebBrowser1.Navigate("http://www.last.fm/api/auth/?api_key=" + My.Settings.api_key + "&token=" + My.Settings.token)
	End Sub

	Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

	End Sub
End Class